package com.cqywc.cjadmin.service;

import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import com.cqywc.cjadmin.mapper.AdminMapper;
import com.cqywc.cjadmin.pojo.Admin;

@Service
public class ReturnSerivice {
	private Integer code;
	private String msg;
	private Map<String, Object> data;
	private Integer page=0;
	private Integer limit=10;
	private Object lists;
	
	 

	public Object getLists() {
		return lists;
	}
	public void setLists(Object lists) {
		this.lists = lists;
	}
	public Integer getPage() {
		return page;
	}
	public void setPage(Integer page) {
		this.page = page;
	}
	public Integer getLimit() {
		return limit;
	}
	public void setLimit(Integer limit) {
		this.limit = limit;
	}
	public Integer getCount() {
		return count;
	}
	public void setCount(Integer count) {
		this.count = count;
	}
	private Integer count;
	
	
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Map<String, Object> getData() {
		return data;
	}
	public void setData(Map<String, Object> data) {
		this.data = data;
	}
	
	@Transactional
	public Admin test() {
		WebApplicationContext wac= ContextLoader.getCurrentWebApplicationContext();
		SqlSessionFactory sqlSessionFactory = (SqlSessionFactory) wac.getBean("sqlSessionFactory");
		SqlSession sqlSession = sqlSessionFactory.openSession();
		AdminMapper adminMapper = sqlSession.getMapper(AdminMapper.class);
		
		Admin admin =new Admin();
		admin.setId(5);
		admin.setUsername("haha5");
		adminMapper.updateByPrimaryKeySelective(admin);
		admin.setId(6);
		int a=1/0;
		admin.setUsername("haha6");
		adminMapper.updateByPrimaryKeySelective(admin);
		return admin;
		
	}
	
	
	
}
